Getting started
1. Hardware settings
SAI_PlaySound program needs this hardware:
- TWR-K64F120M
- TWR-ELEV
- TWR-SGTL
2. Download program
- Download the program to the target board.
- Connect a USB cable to the PC host and open a serial terminal at 115200 baud, 8-bits no parity, 1 stop bit.
- When successfully connected, the program sends the welcome information to the terminal. Communication Interface Settings:
- TWR-K64F120M(OpenSDA) UART1 TX: PC3 RX: PC4.
3. Run the program
If a serial terminal echo inputs normally, use headphones connected to the TWR-SGTL's HEADSET socket and type "play" on the terminal. It plays a short audio clip.
Select different format of wave file
To change the format of a wave data source, change the include file located in main.c.
All available wave files are:
- Note
- 1. SGTL5000 cannot support 8-bit waveform data.
-
2. Wave data source header files are generated by any "BIN to C" tools. They are available on the Internet.
Add your own audio clip
1. Convert your audio file into the Windows PCM wave file format.
- Note
- The wave file should be less than 500 KB provided the internal flash is used as memory media.
2. Write call back function "AppGetData"
(1) Function "PLAYSOUND_Play"
Function "PLAYSOUND_Play" transfers wave data into the codec. The entire wave data does not have to be loaded into memory.
Function prototype:
(2) Prototype of "GetData" function
(3) Description of "GetData" function
The function returns the number of requested bytes. The maximum number of bytes is NumBytesReq.
(4) Example
The following code excerpt shows how to use the function:
{
uint32_t NumBytesRead = 0;
...
...
...
}
Note: sgtl5000 only supports 16bit, 20bit, 24bit and 32bit. Note: 20bit and 24 bit need to do some special operations in application, current application now do not support this. Note: Sgtl5000 only supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate.